﻿@page "/test/2"
@inherits MainBase
@inject HttpClient HttpClient

<LayoutPageTitle>Test webapi call 2</LayoutPageTitle>

<PageHeader
    BreadcrumbItems="@BreadcrumbItems"
    Title="Test webapi call 2"
    Description="Test webapi call 2">
</PageHeader>

@if (IsLoading)
{
    <LoadingIndicator />
}
else
{
    <p>Test 2 OK.</p>
}

@code {
    private bool IsLoading { get; set; } = true;

    /// <inheritdoc />
    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        await base.OnAfterRenderAsync(firstRender);

        if (firstRender)
        {
            await MakeWebApiCall();
        }
    }

    private async Task MakeWebApiCall()
    {
        await HttpClient.GetAsync("v1/Test");

        IsLoading = false;
        StateHasChanged();
    }
}
